package com.data.basic.chapter07;

import java.util.LinkedList;

/**     基于链表实现 的集合  --->简单
 * Created by wangbing on 2018/5/13.
 */
public class LinkedListSet<E extends Comparable<E>> implements MySet<E> {

    private LinkedList <E> linkedList;

    public LinkedListSet() {
        linkedList = new LinkedList<E>();
    }

    public void add(E e) {
        if (!linkedList.contains(e)){
            linkedList.add(e);
        }
    }

    public void remove(E e) {
        linkedList.remove(e);

    }

    public boolean contains(E e) {
        return linkedList.contains(e);
    }

    public int getSize() {
        return linkedList.size();
    }

    public boolean isEmpty() {
        return linkedList.isEmpty();
    }
}
